/*
 * @Author: fengweicong 75202172+fengweicong@users.noreply.github.com
 * @Date: 2022-05-28 01:16:57
 * @LastEditors: fengweicong 75202172+fengweicong@users.noreply.github.com
 * @LastEditTime: 2022-06-17 21:55:56
 * @FilePath: \hotel-management-system2.0\src\router\index.js
 * @Description: 
 * 
 * Copyright (c) 2022 by fengweicong 75202172+fengweicong@users.noreply.github.com, All Rights Reserved. 
 */
import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store/index'
Vue.use(Router)


const router = new Router({
    routes:[
        {//登录界面
            path: '/',
            name: 'page-login',
            component: () => import('@/views/Page-login'),
        },
        {//数据加载界面
            path: '/Loading',
            name: 'Loading',
            component: () => import('@/views/Loading'),
        },
        {//主界面
            path: '/main',
            component: () => import('@/views/Main'),
            children:[
                {//初始界面
                    path: '/',
                    component: () => import('@/views/Init'),
                },
                {//房型管理界面
                    path: 'Room-type',
                    name: 'Room-type',
                    component: () => import('@/views/Room-type'),
                },
                {//房间管理界面
                    path: 'Room',
                    name: 'Room',
                    component: () => import('@/views/Room'),
                },
                {//前台房间管理界面
                    path: 'Room-management',
                    name: 'Room-management',
                    component: () => import('@/views/Room-management'),
                },
                {//预订管理界面
                    path: 'Booking-management',
                    name: 'Booking-management',
                    component: () => import('@/views/Booking-management'),
                },
                {//入住管理界面
                    path: 'Check-in-management',
                    name: 'Check-in-management',
                    component: () => import('@/views/Check-in-management'),
                },
                {//会员管理界面
                    path: 'Member-management',
                    name: 'Member-management',
                    component: () => import('@/views/Member-management'),
                },
                {//商品管理界面
                    path: 'Inventory',
                    name: 'Inventory',
                    component: () => import('@/views/Inventory'),
                },
                {//销售管理界面
                    path: 'Sales',
                    name: 'Sales',
                    component: () => import('@/views/Sales '),
                },
                {//进货管理界面
                    path: 'Stock',
                    name: 'Stock',
                    component: () => import('@/views/Stock '),
                },
                {//进货管理界面
                    path: 'Accouting',
                    name: 'Accouting',
                    component: () => import('@/views/Accouting'),
                },
            ]
        },
    ]
})

//解决跳转到当前路由报错的问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

router.beforeEach((to, from, next) => {
    // console.log(to.path,from.path)
    // if(to.path === '/main/Room') {
    //     console.log("s",store)
    // }
    next()
})

export default router
